package com.example.liuke.guangguang.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.widget.Toast;

/**
 * Created by liuke on 2018/8/27.
 */

public class NetWorkStatusReceiver  extends BroadcastReceiver {
//可以在第一次启动的时候 判断网络可用否可用就启动service，还有在网络变化的时候检测网络是否可用 可用就启动service
    public NetWorkStatusReceiver() {

    }

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
            Toast.makeText(context, "network changed", Toast.LENGTH_LONG).show();

        }
    }
}